package com.atguigu.exam.mapper;


import com.atguigu.exam.entity.Question;
import com.atguigu.exam.vo.QuestionPageVo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * 题目Mapper接口
 * 继承MyBatis Plus的BaseMapper，提供基础的CRUD操作
 */
public interface QuestionMapper extends BaseMapper<Question> {
    List<Question> findQuestionById(Integer id);

    //查询题目中分类的数量
    @Select("select category_id,count(*) ct from questions where is_deleted = 0" + " group by category_id")
    List<Map<Long, Long>> selectCategoryCount();

    //分页查询题目信息
    IPage<Question> customPage(IPage<Question> page, @Param("questionPageVo") QuestionPageVo questionPageVo);

    Question customGetById(Long id);
}